package com.longge.wechat.controller.wx;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.longge.wechat.message.post.PostVideoMessage;
import com.longge.wechat.message.post.Video;
import com.longge.wechat.message.wxUtil.WeiXinUtil;



@Controller
public class PostVideoController {

	@RequestMapping(value = "/respVideo.do", method = RequestMethod.POST)
	protected void doPost2(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		String content = "";
		String openId = (String) request.getAttribute("openId");
		PostVideoMessage pvm = new PostVideoMessage();
		pvm.setTouser(openId);
		pvm.setMsgtype("video");
		Video video = new Video();
		
		video.setMedia_id("media_id");
		video.setTitle("客服发送视频测试");
		video.setDescription("这是客服发送视频测试");
		pvm.setVideo(video);
		int result = WeiXinUtil.sendInfo(pvm);
		if(result == 1) {
			content = "发送视频消息成功";
		}
		System.out.println(content);
	}
}
